package com.lagou.service.impl;

import com.lagou.service.HelloService;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.rpc.RpcContext;

import java.util.Map;

@Service
public class HelloServiceImpl implements HelloService  {

    @Override
    public String sayHello(String name, int timeToWait) {
        Map<String, String> attachments = RpcContext.getContext()
                .getAttachments();
        String parm = attachments.get("ip");
        System.out.println("ip：" + parm);

        return "hello:"+name;
    }

    @Override
    public String test(String msg) {
        System.out.println("消息：" + msg);
        return msg;
    }

    @Override
    public String methodA() {
        int i = (int) (Math.random() * 100);
        try {
            Thread.sleep(i);
        }catch (Exception e){
            e.printStackTrace();
        }

        return "methodA";
    }

    @Override
    public String methodB() {
        int i = (int) (Math.random() * 100);
        try {
            Thread.sleep(i);
        }catch (Exception e){
            e.printStackTrace();
        }
        return "methodB";
    }

    @Override
    public String methodC() {
        int i = (int) (Math.random() * 100);
        try {
            Thread.sleep(i);
        }catch (Exception e){
            e.printStackTrace();
        }
        return "methodC";
    }



}
